package edu.uoc.tdp.pac4.client.logandreg;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import edu.uoc.tdp.pac4.common.util.LanguageUtils;


	


	public class OnTimeAttendancesModel extends AbstractTableModel{
		

		private static final long serialVersionUID = 1L;
		protected Vector<String> listHeaders = new Vector<String>();
		protected List<AttendanceData> atts = new ArrayList<AttendanceData>();
		
		
		public OnTimeAttendancesModel(List<AttendanceData> attsList) {
			setHeader();
			atts = attsList;
		}

		
		protected void setHeader() {
			listHeaders.add(LanguageUtils.getMessage("client.regandlog.tableAtt.header.title1"));
			listHeaders.add(LanguageUtils.getMessage("client.regandlog.tableAtt.header.title2"));
			listHeaders.add(LanguageUtils.getMessage("client.regandlog.tableAtt.header.title3"));
			listHeaders.add(LanguageUtils.getMessage("client.regandlog.tableAtt.header.title4"));
		}

		
		public String getColumnName(int col) {
			return ((String) listHeaders.get(col));
		}

		public int getColumnCount() {
			return listHeaders.size();
		}

		public int getRowCount() {
			if (atts != null)
				return atts.size();
			else
				return 0;
		}

		public Object getValueAt(int rowIndex, int columnIndex) {
			AttendanceData att = null;
			if (atts != null) {
				att = (AttendanceData) atts.get(rowIndex);

				switch (columnIndex) {
				case 0:
					return att.getGroupname();
				case 1:
					return att.getAttendanceDate();
				case 2:
					return att.getStartTime();
				case 3:
					return att.getAttendanceId();
				}
			}
			return att;
		}
		
		public boolean isCellEditable(int row, int column) {
			return (false);
		}


}



